package com.guodi.map.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guodi.map.entity.MapLabel;
import com.guodi.map.mapper.MapLabelMapper;
import com.guodi.map.service.IMapLabelService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @描述：地图标注 服务类
 * @作者: 代鹏刚
 * @日期: 2020-03-30
 */
@Service
public class MapLabelServiceImpl extends ServiceImpl<MapLabelMapper, MapLabel> implements IMapLabelService {

    @Override
    public List<MapLabel> listByEntity(Page page, MapLabel mapLabel) {
        LambdaQueryWrapper<MapLabel> queryWrapper = (new QueryWrapper()).lambda();
        if(StringUtils.isNotBlank(mapLabel.getProjectCode())){
            queryWrapper.eq(MapLabel::getProjectCode,mapLabel.getProjectCode());
        }
        if(StringUtils.isNotBlank(mapLabel.getName())){
            queryWrapper.like(MapLabel::getName,mapLabel.getName());
        }
        if(StringUtils.isNotBlank(mapLabel.getCreator())){
            queryWrapper.eq(MapLabel::getCreator,mapLabel.getCreator());
        }
        if(StringUtils.isNotBlank(mapLabel.getType())){
            queryWrapper.eq(MapLabel::getType,mapLabel.getType());
        }
        return this.list(queryWrapper);
    }
}
